# -*- coding: utf-8 -*-
from urllib import quote
from search.basesearch import basesearch
class SearchSolr(basesearch):
  def __init__(self,logger,host,port="80",path="/",timeout=1.5):
    basesearch.__init__(self,logger,host,port,path,timeout)
    self.logger.debug("%s Init Host:%s port:%s path:%s"%(__name__,self.host,self.port,self.path))
  def _makeUrl(self):
     self.url=None
     qs=quote(self.env_requests['qs'])
     self.url="http://%s:%s/%s/select/?q=%s&%s"%(self.host,self.port,self.path,qs,self._makeSourceRequest())
     self.logger.debug("MakeUrl [%s]"%self.url)
  def setResult(self,res):
     self.logger.debug("result [%s] bytes"%len(res))
     try:
      self.result=unicode(res,"utf-8")
     except:
       #Todo gestire l'eccezzione
       self.result="Unicode error"
       